<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <script th:src="@{/plugins/layui/layui.js}"></script>
    <title>待生产订单查询</title>

</head>
<body>
<div class="margin clearfix">
    <div class="stystems_style">
        <div class="tabbable">
            <div class="page-content clearfix">
                <div id="Member_Ratings">

                    <div class="tab-content">

                        <div id="home" class="tab-pane active">

                            <div class="search_style">
                                <ul class="search_content clearfix">
                                    <li><label class="l_f">查询待生产订单：</label><input name="" type="text" class="text_add"
                                                                                  placeholder="输入订单编号"
                                                                                  style=" width:400px"/></li>
                                    <li><label class="label_name">生产状态：</label><span class="add_name">
		<label><input name="form-field-radio1" type="radio" value="1" class="ace"><span class="lbl">已生产</span></label>&nbsp;&nbsp;&nbsp;
		<label><input name="form-field-radio1" type="radio" value="0" checked="checked" class="ace"><span
                class="lbl">未生产</span></label></span>

                                        <div class="prompt r_f"></div>
                                    </li>
                                    <li style="width:90px;">
                                        <button type="button" class="btn_search"><i class="icon-search"></i>查询</button>
                                    </li>
                                </ul>
                            </div>
                            <table id="demo" lay-filter="demo"></table>
                            <script>
                                layui.use('table', function(){
                                    var table = layui.table;
                                    //第一个实例
                                    table.render({
                                        elem: '#demo'
                                        ,url: '/stayProduction/list' //数据接口
                                        ,page:true
                                        ,cols: [
                                            [ //表头
                                                {field: 'id', title: '序号', sort: true, fixed: 'left', align:'center'}
                                                ,{field: 'ioId', title: '订单编号' , align:'center'}
                                                ,{field: 'productName', title: '产品名称', align:'center' }
                                                ,{field: 'productModel', title: '产品型号', align:'center'}
                                                ,{field: 'orderSum', title: '数量', align:'center'}
                                                ,{field: 'productionName', title: '生产产线', sort: true, align:'center'}
                                                ,{field: 'createTime', title: '生产时间',templet : function (res){
                                                    if (res.createTime == null){
                                                        return ""
                                                    }else {
                                                        return res.createTime
                                                    }
                                                } }
                                                ,{field: 'state', title: '状态',templet:function(res) {
                                                    if (res.state == "1") {
                                                        return '<span style="color: red">已生产</span>'
                                                    }else {
                                                        return '<span style="color: red">未生产</span>'
                                                    }
                                                }}
                                                ,{field: 'remarks', title: '备注', sort: true}
                                            ]]
                                    });

                                });
                            </script>
                        </div>
                    </div>
                    <!--编辑产线图层-->
                    <div class="add_menber" id="add_menber_styl" style="display:none">

                        <ul class=" page-content">

                            <div class="prompt r_f"></div>
                            <li><label class="label_name">生产产线：</label><span class="add_name">
                                <input type="text" id="productName" value=""/>
                            </span>

                                <div class="prompt r_f"></div>
                            </li>
                            <li style="position: relative;left: -5px;"><label class="label_name" style="width: 85px;">使用打印机：</label><span
                                    class="add_name"><select name='使用打印机' id="printer" style='width:200px'>
                                <option value='A1' selected>A1</option>
                                <option value='A2'>A2</option>
                                <option value='A3'>A3</option>
                                <option value='A4'>A4</option>
                            </select></span>

                                <div class="prompt r_f"></div>
                            </li>
                            <li><label class="label_name">生产时间：</label><span class="add_name"><input name="生产时间"
                                                                                                     type="date"
                                                                                                     id="time"
                                                                                                     class="text_add laydate-icon"/></span>

                                <div class="prompt r_f"></div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use('table', function() {
        var table = layui.table;
        var $ = layui.jquery;
        var layer = layui.layer;
        $(".btn_search").click(function () {
            var id = $(".text_add").val();
            var state = $('input:radio[name="form-field-radio1"]:checked').val();
            console.log(id)
            console.log(state)
            table.reload('demo', {
                url: '/stayProduction/like'
                , request: {
                    pageName: 'page'
                    , limitName: 'limit'
                }
                , where: {
                    'orderId': id
                    ,'state':state
                }
                , page: {
                    curr: 1
                }
            })
        });
        //监听工具条
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'upp') {
                $("#productName").val(data.productionName);
                layer.open({
                    type: 1,
                    title: '设置生产记录',
                    maxmin: true,
                    shadeClose: false, //点击遮罩关闭层
                    area: ['800px', ''],
                    content: $('#add_menber_styl'),
                    btn: ['确认加入', '取消'],
                    yes: function (index, layero) {
                        var printer = $("#printer option:selected").val();
                        var createTime = $("#time").val();
                        var productName = $("#productName").val();
                        if (createTime.length==0) {
                            layer.alert("时间不能为空", {
                                title: '提示框',
                                icon: 0,
                            });
                        }
                        else {
                            $.ajax({
                                url : '/stayProduction/upp',
                                type : 'post',
                                data: {'id':data.id,'printer':printer,'productName':productName},
                                dataType : 'json',                          //表示服务器返回给我们的数据是json格式
                                success : function (data) {
                                    if (data == 1) {
                                        layer.open({
                                            title: '提示',
                                            content: '加入成功！是否跳转至该页面？'
                                            , btn: ['确定', '取消'],
                                            yes: function () {
                                                window.location.href = '/production/laser/sc_jgmPage';
                                            }
                                        });
                                    }
                                }
                            })
                            layer.close(index);
                        }
                    }
                });
            }
        });
    })
</script>
</body>
</html>

